package com.woniuxy01;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-10-24 9:27
 */
public class Test07 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("是否开始游戏y/n");
        String answer = scanner.next();
        int random;
        int num;
        while (answer.equals("y")){
            random = (int) (Math.random() * 100);
            System.out.println("random="+random);
            do{
                System.out.println("输入你猜到的数字");
                num=scanner.nextInt();
                if(num>random){
                    System.out.println("猜大了");
                }else if(num<random){
                    System.out.println("猜小了");
                }else{
                    System.out.println("猜对了");
                    break;
                }
            }while (true);
            System.out.println("是否开始下一局游戏y/n");
            answer = scanner.next();
        }
        System.out.println("程序结束");



    }
}
